Skip to content

Reject implementing const Drop for types that are not const Destruct already#155676

Merged
rust-bors[bot] merged 2 commits intorust-lang:mainfrom
oli-obk:const-drop-non-const-destruct
Apr 26, 2026
Merged

Reject implementing const Drop for types that are not const Destruct already#155676
rust-bors[bot] merged 2 commits intorust-lang:mainfrom
oli-obk:const-drop-non-const-destruct

Conversation

@oli-obk
Copy link
Copy Markdown
Contributor

@oli-obk oli-obk commented Apr 23, 2026

fixes #155618

While there is no soundness or otherwise issue currently, this PR ensures that people get what they expect. It seems wrong to allow implementing const Drop, but then the type still can't be dropped at compile-time.

r? @fee1-dead

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 23, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 23, 2026

fee1-dead is not on the review rotation at the moment.
They may take a while to respond.

Copy link
Copy Markdown
Member

@fee1-dead fee1-dead left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

impl_def_id: LocalDefId,
adt_def_id: DefId,
) -> Result<(), ErrorGuaranteed> {
if tcx.is_conditionally_const(impl_def_id) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if tcx.is_conditionally_const(impl_def_id) {
if !tcx.is_conditionally_const(impl_def_id) {
return Ok(());
}

Then the big ocx.evaluate_obligations_error_on_ambiguity() can just be trailing.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 25, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 25, 2026

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@oli-obk oli-obk force-pushed the const-drop-non-const-destruct branch from ad87dce to 7dcedaf Compare April 25, 2026 18:59
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 25, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@oli-obk
Copy link
Copy Markdown
Contributor Author

oli-obk commented Apr 25, 2026

@bors r=fee1-dead rollup

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Apr 25, 2026

📌 Commit 7dcedaf has been approved by fee1-dead

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 25, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Apr 25, 2026
…uct, r=fee1-dead

 Reject implementing const Drop for types that are not const `Destruct` already

fixes rust-lang#155618

While there is no soundness or otherwise issue currently, this PR ensures that people get what they expect. It seems wrong to allow implementing `const Drop`, but then the type still can't be dropped at compile-time.

r? @fee1-dead
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Apr 25, 2026
…uct, r=fee1-dead

 Reject implementing const Drop for types that are not const `Destruct` already

fixes rust-lang#155618

While there is no soundness or otherwise issue currently, this PR ensures that people get what they expect. It seems wrong to allow implementing `const Drop`, but then the type still can't be dropped at compile-time.

r? @fee1-dead
rust-bors Bot pushed a commit that referenced this pull request Apr 25, 2026
…uwer

Rollup of 4 pull requests

Successful merges:

 - #146181 (Add intrinsic for launch-sized workgroup memory on GPUs)
 - #155065 (Error on invalid macho section specifier)
 - #155676 ( Reject implementing const Drop for types that are not const `Destruct` already)
 - #155783 (Do not suggest internal cfg trace attributes)
rust-bors Bot pushed a commit that referenced this pull request Apr 25, 2026
…uwer

Rollup of 9 pull requests

Successful merges:

 - #146181 (Add intrinsic for launch-sized workgroup memory on GPUs)
 - #154803 (Fix ICE from cfg_attr_trace )
 - #155065 (Error on invalid macho section specifier)
 - #155485 (Add an edge-case test for `--remap-path-prefix` for `rustc` & `rustdoc`)
 - #155659 (cleanup, restructure and merge `tests/ui/deriving` into `tests/ui/derives`)
 - #155676 ( Reject implementing const Drop for types that are not const `Destruct` already)
 - #155696 (Add a higher-level API for parsing attributes)
 - #155769 (triagebot.toml: Ping Enselic when tests/debuginfo/basic-stepping.rs changes)
 - #155783 (Do not suggest internal cfg trace attributes)
@rust-bors rust-bors Bot merged commit 2c639cc into rust-lang:main Apr 26, 2026
11 checks passed
@rustbot rustbot added this to the 1.97.0 milestone Apr 26, 2026
rust-timer added a commit that referenced this pull request Apr 26, 2026
Rollup merge of #155676 - oli-obk:const-drop-non-const-destruct, r=fee1-dead

 Reject implementing const Drop for types that are not const `Destruct` already

fixes #155618

While there is no soundness or otherwise issue currently, this PR ensures that people get what they expect. It seems wrong to allow implementing `const Drop`, but then the type still can't be dropped at compile-time.

r? @fee1-dead
@fmease fmease added the PG-const-traits Project group: Const traits label Apr 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PG-const-traits Project group: Const traits S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

const Drop can be implemented for structs with non-const-Drop fields

4 participants